<?php 
defined('IN_TS') or die('Access Denied.');

$authorid = intval($GLOBALS['TS_USER']['userid']);

if($authorid==0){
	echo 0;exit;//请登录
}


$content = tsClean($_POST['content']);
$userid = tsClean($_POST['userid']);

if($GLOBALS['TS_USER']['isadmin']==0){
	//过滤内容开始
	aac('system')->antiWord($content);
	//过滤内容结束
}

$commentid =  $new['user']->create('user_comment',array(
	'userid'=>$userid,
	'content'=>$content,
	'authorid'=>$authorid,
	'addtime'=>date('Y-m-d H:i:s'),
));

// 上传图片开始
$arrUpload = tsUpload ( $_FILES ['filedata'], $commentid, 'user_comment', array ('jpg','gif','png','jpeg' ) );
if ($arrUpload) {
	$new['user']->update ( 'user_comment', array (
		'commentid' => $commentid
	), array (
		'path' => $arrUpload ['path'],
		'photo' => $arrUpload ['url']
	) );

	echo 3;exit;

}else{

	echo 2;exit;

}